﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using System.Windows.Browser;

namespace HCI.Questionaire
{
    public partial class TitlePage : Page
    {
        public TitlePage()
        {
            InitializeComponent();
            panelShine.Begin();
            this.btnExit.Visibility = Visibility.Collapsed;
            this.btnNext.Tag = 0;
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Uri.ToString().ToString().IndexOf("exit") >= 0)
            {
                this.txtTitleDescription1.Visibility = Visibility.Collapsed;
                this.txtTitleDescription2.Visibility = Visibility.Visible;
                //this.btnNext.Visibility = Visibility.Collapsed;
                this.btnNext.Content = "ปิดแบบสอบถาม";
                this.btnNext.Tag = 1;
            }
        }

        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            if (int.Parse(this.btnNext.Tag.ToString()) == 1)
            {
                HtmlPage.Window.Invoke("CloseWindow");
            }
            else
            {
                var result = this.NavigationService.Navigate(new Uri("/QuestionContainerPage", UriKind.RelativeOrAbsolute));
            }
        }

        private void btnExit_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	HtmlPage.Window.Invoke("CloseWindow");
        }

    }
}
